From: mjw@wray-m-3.hpl.hp.com Date: Mon, 21 Jun 2004 13:45:04 +0000 (+0000) Subject: bitkeeper revision 1.990.2.6 (40d6e660Z0vrxCNX22AQw744Qy70rw) X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~18126^2~4 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22?a=commitdiff_plain;h=f2829d6aca4a85ef7d79849ca84a20affe0de410;p=xen.git bitkeeper revision 1.990.2.6 (40d6e660Z0vrxCNX22AQw744Qy70rw) First cut at support for setting the domains for block and net backends. --- diff --git a/tools/xenmgr/lib/XendDomain.py b/tools/xenmgr/lib/XendDomain.py index 94afe3e87d..794c1f2931 100644 --- a/tools/xenmgr/lib/XendDomain.py +++ b/tools/xenmgr/lib/XendDomain.py @@ -18,6 +18,9 @@ import XendDomainInfo import XendConsole import EventServer +from xenmgr.server import SrvConsoleServer +xend = SrvConsoleServer.instance() + eserver = EventServer.instance() __all__ = [ "XendDomain" ] @@ -49,15 +52,16 @@ class XendDomain: def initial_refresh(self): """Refresh initial domain info from domain_db. """ - print "initial_refresh> db=", self.domain_db.values() + print "initial_refresh>" + for d in self.domain_db.values(): print 'db dom=', d domlist = xc.domain_getinfo() - print "doms=", domlist + for d in domlist: print 'xc dom=', d doms = {} for d in domlist: domid = str(d['dom']) doms[domid] = d for config in self.domain_db.values(): - domid = int(sxp.child_value(config, 'id')) + domid = str(sxp.child_value(config, 'id')) print "dom=", domid, "config=", config if domid in doms: print "dom=", domid, "new" @@ -141,7 +145,7 @@ class XendDomain: config = None image = None newinfo = XendDomainInfo.XendDomainInfo( - config, d['dom'], d['name'], d['mem_kb']/1024, image) + config, d['dom'], d['name'], d['mem_kb']/1024, image=image, info=d) self._add_domain(newinfo.id, newinfo) # Remove entries for domains that no longer exist. for d in self.domain.values(): @@ -193,13 +197,13 @@ class XendDomain: """ dom = int(id) eserver.inject('xend.domain.start', id) - return xc.domain_start(dom=dom) + return xend.domain_start(dom) def domain_stop(self, id): """Stop domain running. """ dom = int(id) - return xc.domain_stop(dom=dom) + return xend.domain_stop(dom) def domain_shutdown(self, id): """Shutdown domain (nicely). @@ -208,7 +212,7 @@ class XendDomain: if dom <= 0: return 0 eserver.inject('xend.domain.shutdown', id) - val = xc.domain_destroy(dom=dom, force=0) + val = xend.domain_destroy(dom, force=0) self.refresh() return val @@ -219,7 +223,7 @@ class XendDomain: if dom <= 0: return 0 eserver.inject('xend.domain.halt', id) - val = xc.domain_destroy(dom=dom, force=1) + val = xend.domain_destroy(dom, force=1) self.refresh() return val diff --git a/tools/xenmgr/lib/XendDomainInfo.py b/tools/xenmgr/lib/XendDomainInfo.py index 61a9b21c5a..ec9258afd8 100644 --- a/tools/xenmgr/lib/XendDomainInfo.py +++ b/tools/xenmgr/lib/XendDomainInfo.py @@ -59,7 +59,7 @@ class VmError(ValueError): class XendDomainInfo: """Virtual machine object.""" - def __init__(self, config, dom, name, memory, image=None, console=None): + def __init__(self, config, dom, name, memory, image=None, console=None, info=None): """Construct a virtual machine object. config configuration @@ -78,8 +78,10 @@ class XendDomainInfo: self.console = console self.devices = {} self.configs = [] - self.info = None + self.info = info self.ipaddrs = [] + self.block_controller = 0 + self.net_controller = 0 #todo: state: running, suspended self.state = 'running' @@ -111,6 +113,7 @@ class XendDomainInfo: ['name', self.name], ['memory', self.memory] ] if self.info: + print 'info:', self.info run = (self.info['running'] and 'r') or '-' block = (self.info['blocked'] and 'b') or '-' stop = (self.info['stopped'] and 's') or '-' @@ -528,6 +531,18 @@ def vm_create_devices(vm, config): print '' val = unpackMsg('blkif_be_create_t', msg) @@ -81,15 +84,20 @@ class BlkifControllerFactory(controller.ControllerFactory): blkif = self.getInstanceByDom(dom) if blkif: blkif.reattach_device(vdev) + self.attached = self.devices_attached() + if self.attached: + self.reattached() + + def devices_attached(self): + """Check if all devices are attached. + """ attached = 1 for blkif in self.getInstances(): if not blkif.attached: attached = 0 break - self.attached = attached - if self.attached: - self.reattached() - + return attached + def reattached(self): for blkif in self.getInstances(): blkif.reattached() @@ -149,12 +157,16 @@ class BlkifController(controller.Controller): return self.factory.addDeferred() def detach(self): + """Detach all devices, when the back-end control domain has changed. + """ self.attached = 0 for dev in self.devices.values(): dev.attached = 0 self.send_be_vbd_create(vdev) def reattach_device(self, vdev): + """Reattach a device, when the back-end control domain has changed. + """ dev = self.devices[vdev] dev.attached = 1 attached = 1 @@ -166,6 +178,8 @@ class BlkifController(controller.Controller): return self.attached def reattached(self): + """All devices have been reattached after the back-end control domain has changed. + """ msg = packMsg('blkif_fe_interface_status_changed_t', { 'handle' : 0, 'status' : BLKIF_INTERFACE_STATUS_DISCONNECTED}) diff --git a/tools/xenmgr/lib/server/netif.py b/tools/xenmgr/lib/server/netif.py index 7403054409..13bdd96486 100755 --- a/tools/xenmgr/lib/server/netif.py +++ b/tools/xenmgr/lib/server/netif.py @@ -35,6 +35,7 @@ class NetifControllerFactory(controller.ControllerFactory): def setControlDomain(self, dom): """Set the 'back-end' device driver domain. """ + if self.dom == dom: return self.deregisterChannel() self.attached = 0 self.dom = dom @@ -44,7 +45,9 @@ class NetifControllerFactory(controller.ControllerFactory): # xend.netif.recovery = True # xend.netif.be_port = xend.main.port_from_dom(dom) # - pass + + def getControlDomain(self): + return self.dom def recv_be_create(self, msg, req): self.callDeferred(0) @@ -64,6 +67,8 @@ class NetifControllerFactory(controller.ControllerFactory): val = unpackMsg('netif_be_driver_status_changed_t', msg) status = val['status'] if status == NETIF_DRIVER_STATUS_UP and not self.attached: + # If we are not attached the driver domain was changed, and + # this signals the new driver domain is ready. for netif in self.getInstances(): netif.reattach_devices() self.attached = 1 @@ -149,6 +154,8 @@ class NetifController(controller.Controller): return d def reattach_devices(self): + """Reattach all devices when the back-end control domain has changed. + """ d = self.factory.addDeferred() self.send_be_create(vif) self.attach_fe_devices(0) @@ -182,10 +189,6 @@ class NetifController(controller.Controller): 'rx_shmem_frame' : val['rx_shmem_frame'] }) self.factory.writeRequest(msg) - #def recv_fe_interface_status_changed(self): - # print 'recv_fe_interface_status_changed>' - # pass - def send_interface_connected(self, vif): dev = self.devices[vif] msg = packMsg('netif_fe_interface_status_changed_t',